package com.timguan.render.api.entity.dataprocessor;

import java.io.Serializable;
import java.util.List;

/**
 * 以天为单位对数据进行分组
 * Created by guankaiqiang on 2015/7/7.
 */
public class ItemGroupByDay implements Serializable {
    //时间线
    private String dayLineStart;
    private String dayLineEnd;
    private String dayLineFrontDesc;
    private List<ItemGroupByHour> itemGroupByHours;

    public ItemGroupByDay(String dayLineStart, String dayLineFrontDesc, List<ItemGroupByHour> itemGroupByHours) {
        this.dayLineStart = dayLineStart;
        this.dayLineFrontDesc = dayLineFrontDesc;
        this.itemGroupByHours = itemGroupByHours;
    }

    public String getDayLineFrontDesc() {
        return dayLineFrontDesc;
    }

    public void setDayLineFrontDesc(String dayLineFrontDesc) {
        this.dayLineFrontDesc = dayLineFrontDesc;
    }

    public String getDayLineStart() {
        return dayLineStart;
    }

    public void setDayLineStart(String dayLineStart) {
        this.dayLineStart = dayLineStart;
    }

    public String getDayLineEnd() {
        return dayLineEnd;
    }

    public void setDayLineEnd(String dayLineEnd) {
        this.dayLineEnd = dayLineEnd;
    }

    public List<ItemGroupByHour> getItemGroupByHours() {
        return itemGroupByHours;
    }

    public void setItemGroupByHours(List<ItemGroupByHour> itemGroupByHours) {
        this.itemGroupByHours = itemGroupByHours;
    }

    /**
     * 根据开始时间查找对应的时间分组
     *
     * @param hourStart
     * @return
     */
    public ItemGroupByHour findItemGroupByHourStart(String hourStart) {
        if (itemGroupByHours != null) {
            for (ItemGroupByHour itemGroupByHour : itemGroupByHours) {
                if (hourStart.equalsIgnoreCase(itemGroupByHour.getHourLineStart())) {
                    return itemGroupByHour;
                }
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "ItemGroupByDay{" +
                ", dayLineStart='" + dayLineStart + '\'' +
                ", dayLineEnd='" + dayLineEnd + '\'' +
                ", dayLineFrontDesc='" + dayLineFrontDesc + '\'' +
                ", itemGroupByHours=" + itemGroupByHours +
                '}';
    }

    /**
     * 以小时为单位对数据进行分组
     */
    public static class ItemGroupByHour implements Serializable {
        //时间线
        private String hourLineStart;
        private String hourLineEnd;
        private String hourLineFrontDesc;
        private List<Object> items;

        public ItemGroupByHour(String hourLineStart, String hourLineFrontDesc, List<Object> items) {
            this.hourLineStart = hourLineStart;
            this.hourLineFrontDesc = hourLineFrontDesc;
            this.items = items;
        }

        public String getHourLineFrontDesc() {
            return hourLineFrontDesc;
        }

        public void setHourLineFrontDesc(String hourLineFrontDesc) {
            this.hourLineFrontDesc = hourLineFrontDesc;
        }

        public List<Object> getItems() {
            return items;
        }

        public void setItems(List<Object> items) {
            this.items = items;
        }

        public String getHourLineStart() {
            return hourLineStart;
        }

        public void setHourLineStart(String hourLineStart) {
            this.hourLineStart = hourLineStart;
        }

        public String getHourLineEnd() {
            return hourLineEnd;
        }

        public void setHourLineEnd(String hourLineEnd) {
            this.hourLineEnd = hourLineEnd;
        }

        @Override
        public String toString() {
            return "ItemGroupByHour{" +
                    ", hourLineStart='" + hourLineStart + '\'' +
                    ", hourLineEnd='" + hourLineEnd + '\'' +
                    ", hourLineFrontDesc='" + hourLineFrontDesc + '\'' +
                    ", items=" + items +
                    '}';
        }
    }
}
